home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / netzwerk / parnet / sources / wakeup.asm < prev   
Assembly Source File  |  1996-02-26  |  3KB  |  178 lines

  1.  
  2.         ;   WAKEUP.ASM
  3.         ;
  4.  
  5.         section __MERGED,DATA
  6.  
  7.         xdef    _VTask
  8.         xdef    _VMask
  9.  
  10. _VTask        dc.l    0
  11. _VMask        dc.l    0
  12.  
  13. MiscRes     dc.l    0
  14. CIARes        dc.l    0
  15. CIBRes        dc.l    0
  16. MiscName    dc.b    'misc.resource',0
  17. CIAName     dc.b    'ciaa.resource',0
  18. CIBName     dc.b    'ciab.resource',0
  19.  
  20.         ;   ICR interrupt
  21.  
  22.         section text,code
  23.  
  24.         xref    _SysBase
  25.         xref    _LVOSignal
  26.         xref    _LVOOpenResource
  27.         xdef    @VInt
  28.         xdef    _VInt
  29.  
  30. @VInt:
  31. _VInt:        move.l    _SysBase,A6
  32.         move.l    _VTask,A1
  33.         move.l    _VMask,D0
  34.         jsr    _LVOSignal(A6)
  35.         moveq.l #1,D0        ; clear interrupt.
  36.         rts
  37.  
  38.         ;   VAddICRVector(cia#, intnum, int)
  39.         ;   VRemICRVector(cia#, intnum, int)
  40.         ;
  41.         ;   cia# : 0 = ciaa, 1 = ciab
  42.  
  43.         xdef    _VAddICRVector
  44.         xdef    _VRemICRVector
  45.         xdef    _VSetICR
  46.         xdef    _VAbleICRA        ; enable/disable ints for CIAA.
  47.         xref    _LVOAbleICR
  48.         xref    _LVORemICRVector
  49.         xref    _LVOAddICRVector
  50.         xref    _LVOSetICR
  51.  
  52. _VAbleICRA:    move.l    A6,-(sp)
  53.         move.l    CIARes,D0
  54.         bne    .vaica10
  55.         bsr    GetCIAResource        ; D0 = 0, get resource for ciaa
  56. .vaica10    move.l    D0,A6            ; assume it works <sigh>.
  57.         move.l    4+4(sp),D0          ; D0 = mask
  58.         jsr    _LVOAbleICR(A6)
  59.         move.l    (sp)+,A6
  60.         rts
  61.  
  62. _VSetICR:
  63.         move.l    A6,-(sp)
  64.         move.l    4+4(sp),D0
  65.         bsr    GetCIAResource
  66.         tst.l    D0
  67.         beq    .badres
  68.         move.l    4+8(sp),D0      ; mask
  69.         jsr    _LVOSetICR(A6)
  70.         move.l    (sp)+,A6
  71.         rts
  72.  
  73. _VAddICRVector:
  74.         move.l    A6,-(sp)
  75.         move.l    4+4(sp),D0
  76.         bsr    GetCIAResource
  77.         tst.l    D0
  78.         beq    .badres
  79.         move.l    4+8(sp),D0
  80.         move.l    4+12(sp),A1
  81.         jsr    _LVOAddICRVector(A6)
  82.         move.l    (sp)+,A6
  83.         rts
  84.  
  85. _VRemICRVector:
  86.         move.l    A6,-(sp)
  87.         move.l    4+4(sp),D0
  88.         bsr    GetCIAResource
  89.         tst.l    D0
  90.         beq    .badres
  91.         move.l    4+8(sp),D0
  92.         move.l    4+12(sp),A1
  93.         jsr    _LVORemICRVector(A6)
  94.         move.l    (sp)+,A6
  95.         rts
  96.  
  97. .badres     moveq.l #-1,D0
  98.         move.l    (sp)+,A6
  99.         rts
  100.  
  101.         ;   Retrieve CIAA (D0 = 0) or CIAB (D0 != 0) resource
  102.  
  103. GetCIAResource:
  104.         move.l    _SysBase,A6
  105.         tst.l    D0
  106.         bne    .gcr100
  107.         move.l    CIARes,D0
  108.         bne    .gcrrts
  109.         lea    CIAName,A1
  110.         jsr    _LVOOpenResource(A6)
  111.         move.l    D0,CIARes
  112.         bra    .gcrrts
  113.  
  114. .gcr100     move.l    CIBRes,D0
  115.         bne    .gcrrts
  116.         lea    CIBName,A1
  117.         jsr    _LVOOpenResource(A6)
  118.         move.l    D0,CIBRes
  119.  
  120. .gcrrts     move.l    D0,A6
  121.         rts
  122.  
  123.  
  124.  ;
  125.  ;  EXEC resource support
  126.  ;                   4(sp)  8(sp)
  127.  ;    AutoAllocMiscResource(resno, value)
  128.  ;        resno:  MR_SERIALPORT, SERIALBITS, PARALLELPORT, PARALLELBITS
  129.  ;        value:  -1 to allocate, 0 to check
  130.  ;
  131.  ;        returns 0 on success
  132.  ;
  133.  ;    AutoFreeMiscResource(resno)
  134.  ;                  4(sp)
  135.  ;        Free a misc resource you allocated
  136.  ;
  137.  ;    No need to open the misc.resource
  138.  
  139.         xdef    _AutoAllocMiscResource
  140.         xdef    _AutoFreeMiscResource
  141.  
  142. _AutoAllocMiscResource:
  143.         move.l    A6,-(sp)
  144.         bsr    OpenMiscResource
  145.         beq    amfail
  146.         move.l    8(sp),D0
  147.         move.l    12(sp),A1
  148.         jsr    -6(A6)
  149.         bra    amret
  150. amfail        moveq.l #-1,D0
  151. amret        move.l    (sp)+,A6
  152.         rts
  153.  
  154. _AutoFreeMiscResource:
  155.         move.l    A6,-(sp)
  156.         bsr    OpenMiscResource
  157.         beq    fmret
  158.         move.l    8(sp),D0
  159.         jsr    -12(A6)
  160. fmret        move.l    (sp)+,A6
  161.         rts
  162.  
  163. OpenMiscResource:
  164.         move.l    MiscRes,D0
  165.         bne    .omr10
  166.         move.l    4,A6
  167.         lea.l    MiscName,A1
  168.         jsr    _LVOOpenResource(A6)
  169. .omr10        move.l    D0,A6
  170.         tst.l    D0
  171.         rts
  172.  
  173.         END
  174.  
  175.  
  176.  
  177.  
  178.